<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>{:session('cp.cpsysname')}--服务商管理平台</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
        <meta name="description" content="{:config('webconfig.description');}">
        <meta name="keywords" content="{:config('webconfig.keywords');}">
        <meta name="author" content="runoob">
        <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
        <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
        <META HTTP-EQUIV="Expires" CONTENT="0">
        <link rel="stylesheet" href="__STATIC_URL__/static/bootstrap/3.3.7/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
        <link rel="stylesheet" href="__STATIC_URL__/static/css/addmchat.css"/>
        <script src="__STATIC_URL__/static/jquery/2.2.1/jquery.min.js"></script>
        <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>
        <script src="__STATIC_URL__/static/layer/layer.js"></script>
    </head>
    <style>
        .filePicker{
            margin-top: -5px;
            width: 150px;
            height: 44px;
            background: #00A2D4;
            color: #fff;
            text-align: center;
            line-height: 44px;
            border-radius: 4px;
            cursor: pointer;
        }
        .file{
            position: absolute;
            left: 14px;
            top: -5px;
            width: 150px;
            height: 44px;
            line-height: 44px;
            opacity: 0;
            cursor: pointer;
        }
        #myTabContent .img-file{
            width: 100px;
            height: 100px;
            display: block;
            margin-left: 26px;
            margin-top: 10px;
            display: none;
        }
        .fade{
            display: none;
        }
        .fade.active{
            display: block;
        }
    </style>
    <body>

    {include file='public/header'/}
    <!------------------导航-------------------------->
    <section>
        {include file='public/left'/}
        <!--------------------------主要内容区域------------------------------------->
        <div class="content">
            <div class="page-heading mgl15 mgr15">
                <ul class="breadcrumb">
                    <li>
                        当前位置是&nbsp;:&nbsp;
                    </li>
                    <li><a href="javascript:histort.back();">代理商管理</a></li>
                    <li class="active" style="color: #02b87f;"> 添加代理商</li>
                </ul>
            </div>
            <div class="panel panel-default mgl15 mgr15">
                <div class="panel-heading addCharts" style="background:#ededed;">添加代理商</div>
                <div class="panel-body">
                    <ul id="myTab" class="nav nav-tabs">
                        <li class="active">
                            <a href="#info" data-toggle="tab">基本信息</a>
                        </li>
                        <li>
                            <a href="#dalifs" data-toggle="tab">支付信息</a>
                        </li>
                    </ul>
                    <div id="myTabContent" class="tab-content" style="padding-top:15px;">
                        <form class="form-horizontal adminex-form" action="" method="post" id="tongdao" enctype="multipart/form-data">
                            <div id="info" class="tab-pane fade in active">
                                <div class="form-group">
                                    <label class="col-sm-2 col-sm-2 control-label">代理商</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control ipt4" id="agentname" name="name"  value="" >
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 col-sm-2 control-label">用户名</label>
                                    <div class="col-sm-10">
                                        <input type="text" id="username" name="username" class="form-control ipt4" >
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 col-sm-2 control-label">密码</label>
                                    <div class="col-sm-10">
                                        <input type="text" id="password" name="password" class="form-control ipt4" >
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 col-sm-2 control-label">联系人</label>
                                    <div class="col-sm-10">
                                        <input type="text" id="contacts" name="contacts" class="form-control ipt4" >
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="col-sm-2 col-sm-2 control-label">电话</label>
                                    <div class="col-sm-10">
                                        <input type="text" id="tel" name="tel" class="form-control ipt4" >
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="col-sm-2 col-sm-2 control-label">联系地址</label>
                                    <div class="col-sm-10">
                                        <input type="text" id="address" name="address" class="form-control ipt4" >
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="col-sm-2 col-sm-2 control-label">开户时间</label>
                                    <div class="col-sm-10">
                                        <input type="text" name="times" class="form-control" value="" placeholder="请选择开始时间" readonly="readonly" id="starttime">
                                    </div>
                                </div>
                            </div>
                            <div id="dalifs" class="tab-pane fade">
                                <ul id="myTab1" class="nav nav-tabs">
                                    <li class="active">
                                        <a href="#tab_weixin" data-toggle="tab">微信通道</a>
                                    </li>
                                    <li>
                                        <a href="#tab_zfb" data-toggle="tab">支付宝通道</a>
                                    </li>
                                    <li>
                                        <a href="#tab_bank" data-toggle="tab">民生通道</a>
                                    </li>
                                </ul>
                                <div id="myTabContent1" class="tab-content" style="padding-top:15px;">
                                    <div class="tab-pane fade in active" id="tab_weixin">
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">应用ID(APPID)</label>
                                            <div class="col-sm-10">
                                                <input type="text" class="form-control ipt4" id="appid" name="appid" value="">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">AppSecret(应用密钥)</label>
                                            <div class="col-sm-10">
                                                <input type="text" id="appsecret" name="appsecret" class="form-control ipt4" value="">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">商户号</label>
                                            <div class="col-sm-10">
                                                <input type="text" id="partnerid" name="partnerid" class="form-control ipt4" value="">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">商户密钥</label>
                                            <div class="col-sm-10">
                                                <input type="text" id="partnerkey" name="partnerkey" class="form-control ipt4" value="">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">上传证书cert</label>
                                            <div class="col-sm-10">
                                                <div class="filePicker" id="file0">选择证书</div>
                                                <input type="file" id="val-file0" name="file" class="file" onchange="upload('val-file0')"/>
                                                <input type="hidden" class="file-val-file0" name="cert" value="" />
                                                <div class="val-file0"></div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">上传证书key</label>
                                            <div class="col-sm-10">
                                                <div class="filePicker" id="file1">选择证书</div>
                                                <input type="file" id="val-file1" name="file" class="file" onchange="upload('val-file1')"/>
                                                <input type="hidden" class="file-val-file1" name="key" value="" />
                                                <div class="val-file1"></div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">上传证书rootca</label>
                                            <div class="col-sm-10">
                                                <div class="filePicker" id="file2">上传证书</div>
                                                <input type="file" id="val-file2" name="file" class="file" onchange="upload('val-file2')"/>
                                                <input type="hidden" class="file-val-file2" name="rootca" value="" />
                                                <div class="val-file2"></div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="tab-pane fade" id="tab_zfb">
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">应用ID</label>
                                            <div class="col-sm-10">
                                                <input type="text" class="form-control ipt4" id="ali_app_id" name="ali_app_id" value="">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">合作伙伴ID</label>
                                            <div class="col-sm-10">
                                                <input type="text" id="sys_service_provider_id" name="sys_service_provider_id" class="form-control ipt4" value="">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">支付宝RAS密钥</label>
                                            <div class="col-sm-10">
                                                <textarea type="text" id="ali_app_key" name="ali_app_key" class="form-control" style="resize: none; width:80%;height:200px;"></textarea>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="tab-pane fade" id="tab_bank">
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">证书</label>
                                            <div class="col-sm-10">
                                                <input type="text" id="cmmb_mch_id" name="cmmb_mch_id" class="form-control">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 col-sm-2 control-label">密钥key</label>
                                            <div class="col-sm-10">
                                                <input type="text" id="cmmb_key" name="cmmb_key" class="form-control">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div style="text-align: center">
                                <button type="submit" class="btn btn-primary">确认提交</button>
                            </div>
                        </form>
                    </div>

                    </div>
                </div>
            {include file='public/footer'/}

        </div>
    </section>
    <script src="__STATIC_URL__/static/layer/layer.js"></script>
    <script src="__STATIC_URL__/static/laydate/laydate.js"></script>
    <script>
        laydate.render({
            elem: '#starttime',
            type: 'datetime',
            range:'-',
            change: function(value, date,endDate){ //监听日期被切换

//比较时间


            }
        });

    </script>
    <script>
        function upload(file) {
            //检验图片格式
            var filename = $("#"+file).val();
            var patterArr = ['pem'];
            var strTip = "上传";
            if (filename == "") {
                alert("请先选择需要" + strTip + "的文件");
                return false;
            } else {
                var patter = eval("/(" + patterArr.join("|") + ")/");
                if (!patter.test(filename.substring(filename.lastIndexOf("."), filename.length).toLowerCase())) {
                    alert("请选择后缀名为" + patterArr.join(",") + "的文件" + strTip);
                    $("#"+file).val("");
                    return false;
                }
                //文件上传
                var formData = new FormData();
                formData.append('file', $('#' + file)[0].files[0]);
                $.ajax({
                    url: "{:url('uploads/uploadpem')}",
                    type: 'POST',
                    cache: false,
                    data: formData,
                    processData: false,
                    contentType: false,
                    beforeSend:function(){
                        //加载层
                        index = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
                    },
                    success:function (res) {
                        layer.close(index);
                        if(res.url!=""){
                            $("."+file).css("color","red").text("上传成功");
                            $(".file-"+file).val(res.url);
                        }else{
                            $("."+file).css("color","red").text("上传失败");
                        }
                    },
                    error:function(){
                        layer.close(index);
                        alert("上传失败")
                    }
                })

    </script>
</body>
</html>
